package cn.signalpha.modules.com.controller.api;

import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.core.tool.utils.Func;
import cn.signalpha.modules.com.entity.UserBank;
import cn.signalpha.modules.com.service.UserBankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * 控制器
 *
 * @author signalpha
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_NAME_PREFIX + "biz/wap/user/bank")
@Api(value = "用户银行卡", tags = "用户银行卡")
public class ApiUserBankController extends BaseController {

	private final UserBankService userBankService;

    @GetMapping("/list")
    @ApiOperation(value = "列表", notes = "")
    public R<List<UserBank>> list(@ApiIgnore @RequestParam Map<String, Object> params) {
		params.put("userId", getUser().getUserId());
        return R.data(userBankService.list(userBankService.selectUserBankWrapper(params)));
    }

	@GetMapping("/info")
	@ApiOperation(value = "详情", notes = "传入id")
	public R<UserBank> info(@ApiParam(value = "主键", required = true) @RequestParam Long id) {
		return R.data(userBankService.getById(id));
	}

	@PostMapping("/remove")
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(userBankService.removeByIds(Func.toLongList(ids)));
	}

}
